﻿//
// Copyright (c) 2024 BPer
//

#ifndef BPERSCTP_H_
#define BPERSCTP_H_

#include <bperutil/BPerType.h>
#include <bperutil/BPerAvType.h>

#if BPer_Enable_Datachannel
#include <usrsctp.h>

#define BPER_SCTP_MTU                         1188
#define BPER_SCTP_ASSOCIATION_DEFAULT_PORT    5000
typedef struct{
	uint16_t streamId;
	uint16_t maxPacketLifeTime;
	uint16_t maxRetransmits;
	uint16_t ordered;
	struct sctp_sendv_spa spa;
	struct socket *local_sock;
	void* user;
	void (*send_dtls_msg)(void* user,char* data,int32_t nb);
	void (*receive_msg)(void* user,uint16_t streamId, uint16_t ssn, uint32_t ppid, int flags, uint8_t* data, size_t len);
}BPerSctp;

void bPer_create_sctp(BPerSctp* sctp);
void bPer_destroy_sctp(BPerSctp* sctp);
void bPer_sctp_sendData(BPerSctp* sctp,BPerFrame* msgFrame);
void bPer_sctp_receiveData(BPerSctp* sctp,char* data,int32_t nb);
#endif
#endif /* BPERSCTP_H_ */
